﻿



$(function () {
    initFinanceTypeSelect()
    Show()
})
function refesh() {
    location.reload();
}
//显示
function Show() {
    layui.use(['form', 'table'], function () {
        var table = layui.table;
        var financeTypeName = $("#financeTypeName").val();

        $.ajax({
            url: '/Purchase/GetFinanceTypeShow',
            type: "get",
            data: {
                financeTypeName: financeTypeName,
                token: localStorage.getItem("token"),
            },
            success: function (data) {
                data = JSON.parse(data);
                console.log(data.data);
                if (data.code == 0) {
                    table.render({
                        elem: financeTotal,
                        data: data.data,
                        toolbar: '#toolbarDemo',
                        defaultToolbar: ['exports'],
                        cols: [[
                            { type: 'checkbox', fixed: 'left' },
                            { field: 'financeTypeNo', title: '流水号' },
                            { field: 'financeTypeName', title: '名称' },
                            { field: 'financeTyperemark', title: '分类' },
                            { field: 'financeTyperemark', title: '收款方/付款方' },
                            { field: 'financeTyperemark', title: '类型' },
                            { field: 'financeTyperemark', title: '付款金额' },
                            { field: 'financeTyperemark', title: '付款时间' },
                            { field: 'financeTyperemark', title: '付款方式' },
                            { field: 'financeTyperemark', title: '付款机构' },
                        ]],
                    });
                } else {
                    console.log(res.msg)
                }
            },
            error: function () {
                console.log("请求失败")
            }
        });
    });
}
//财务类型下拉框
function initFinanceTypeSelect() {
    layui.use('form', function () {
        var form = layui.form;
        $.ajax({
            url: "../Purchase/GetFinanceTypeShow",
            type: "get",
            data: { token: localStorage.getItem("token") },
            success: function (data) {
                var obj = JSON.parse(data);
                console.log(obj)
                var options = '<option value="">请选择</option>'; // 添加默认选项
                $.each(obj.data, function (index, item) {
                    options += '<option value="' + item.financeTypeName + '">' + item.financeTypeName + '</option>';
                });
                $(".dialog-select#financeTypeName").html(options);
                form.render('select'); // 重新渲染下拉框
            },
            error: function () {
                console.log("获取数据失败");
            }
        });
    });
}